#include <iostream>
#include <thread>
#include <atomic>

using std::cout;
using std::endl;
using std::thread;
using std::atomic;

atomic<int> gCnt(0);

void threadFunc()
{
    for(size_t idx = 0; idx != 10000000; ++idx)
    {
        ++gCnt;//gCnt   ++  gCnt
    }
}

int main(int argc, char *argv[])
{
    thread tha(threadFunc);
    thread thb(threadFunc);

    tha.join();
    thb.join();

    cout << "gCnt = " << gCnt << endl;
    return 0;
}

